package com.itheima.day14.day14work1;

import java.util.concurrent.Callable;

public class ShiTiDian implements Callable<Integer> {
    private  Water w;
    public ShiTiDian(Water w) {
        this.w=w;
    }


    @Override
    public Integer call() throws Exception {
        int count = 0;

        while (true) {
            synchronized (w.getObj()) {
                int num = w.getNum();
                if (num<=0){
                break;
                }
              //  Thread.sleep(100);
                count++;
                System.out.println("实体店卖出一杯水，剩余" + (--num));
                w.setNum(num);

            }
                   }
        return count;
    }
}
